var t = getApp();

Page({
    data: {
        store_id: "",
        label_id: "",
        imgList: [],
        navList: [],
        playVideoSrc: "",
        page: 1,
        finished: !1
    },
    onLoad: function(t) {
        t.store_id && this.setData({
            store_id: t.store_id
        }), this.getData();
    },
    onShow: function() {},
    changeTab: function(t) {
        this.setData({
            page: 1,
            finished: !1,
            imgList: [],
            label_id: t.detail.name
        }), this.getData();
    },
    getData: function() {
        var a = this;
        if (!this.data.finished) {
            var e = t.getNetAddresss("plugin.store-alone-temp.frontend.home.get-photo");
            wx.showLoading({
                title: "loading"
            }), t._postNetWork({
                url: e,
                data: {
                    store_id: this.data.store_id,
                    label_id: this.data.label_id,
                    page: this.data.page
                },
                success: function(t) {
                    if (wx.hideLoading(), 1 === t.data.result) {
                        var e, i, s = t.data.data.data;
                        (s.current_page >= s.last_page || s.data.length < s.per_page) && (e = !0), i = a.data.page > 1 ? a.data.imgList.concat(s.data) : s.data, 
                        a.setImgList(i), a.setData({
                            imgList: i,
                            finished: e,
                            page: a.data.page + 1,
                            navList: t.data.data.nav
                        });
                    } else wx.showToast({
                        title: t.data.msg,
                        icon: "none"
                    });
                },
                fail: function() {
                    wx.hideLoading();
                }
            });
        }
    },
    setImgList: function(t) {
        t.forEach(function(t, a) {
            0 == t.data_type && (t.image_src = "".concat(t.image_src, "?id=").concat(a));
        });
    },
    palyVideo: function(t) {
        var a = t.currentTarget.dataset.videosrc;
        this.setData({
            playVideoSrc: a
        });
        var e = wx.createVideoContext("polyvLiveVideo");
        e.requestFullScreen({
            direction: 90
        }), e.seek(0), e.play();
    },
    previewImage: function(t) {
        var a = t.currentTarget.dataset.imagesrc, e = [];
        this.data.imgList.forEach(function(t) {
            0 == t.data_type && e.push(t.image_src);
        }), wx.previewImage({
            current: a,
            urls: e,
            showmenu: !0,
            fail: function() {
                wx.showToast({
                    title: "图片预览失败",
                    icon: "none"
                });
            }
        });
    },
    onReachBottom: function() {
        this.getData();
    }
});